package bb.lanxing.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;


public class ListenerKeyboardLayout extends LinearLayout {
    private OnKeyboardStateChangeListener onKeyboardStateChangeListener;


    public interface OnKeyboardStateChangeListener {
        void keyboardStateChange(boolean z);
    }

    public ListenerKeyboardLayout(Context context) {
        this(context, null);
    }

    public ListenerKeyboardLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public ListenerKeyboardLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public void setOnKeyboardStateChangeListener(OnKeyboardStateChangeListener onKeyboardStateChangeListener) {
        this.onKeyboardStateChangeListener = onKeyboardStateChangeListener;
    }

    @Override
    protected void onMeasure(int i, int i2) {
        OnKeyboardStateChangeListener onKeyboardStateChangeListener;
        OnKeyboardStateChangeListener onKeyboardStateChangeListener2;
        int size = MeasureSpec.getSize(i2);
        int height = getHeight();
        if (size != 0 && height != 0) {
            if (height - size > 100 && (onKeyboardStateChangeListener2 = this.onKeyboardStateChangeListener) != null) {
                onKeyboardStateChangeListener2.keyboardStateChange(true);
            }
            if (size - height > 100 && (onKeyboardStateChangeListener = this.onKeyboardStateChangeListener) != null) {
                onKeyboardStateChangeListener.keyboardStateChange(false);
            }
        }
        super.onMeasure(i, i2);
    }
}
